﻿namespace Lonntec.DevClient
{
    using log4net;
    using Lonntec.AutoUpdate;
    using System;
    using System.Windows.Forms;

    internal static class Program
    {
        private static readonly ILog logger = LogManager.GetLogger(typeof(ApplicationRun));

        [STAThread]
        private static void Main(string[] args)
        {
            try
            {
                bool flag;
                new AutoUpdateClient().Update("DevClient", out flag);
                if (flag)
                {
                    MessageBox.Show("部分更新需要在应用程序重启后才能生效，点击确定后程序将退出！", "系统更新成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }
            }
            catch (Exception exception)
            {
                logger.Error(exception);
                if (MessageBox.Show("检测系统更新时发生了意外错误：“" + exception.Message + "”，您要继续运行程序吗？", "系统更新失败", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
            }
            try
            {
                using (ApplicationRun run = new ApplicationRun(args))
                {
                    try
                    {
                        run.Start();
                    }
                    catch (Exception exception2)
                    {
                        logger.Error(exception2);
                    }
                }
            }
            catch (Exception exception3)
            {
                logger.Error(exception3);
            }
        }
    }
}

